﻿<navigation:Page x:Class="CRM.Tools.MetadataBrowser.Views.EntityView" 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
           xmlns:local="clr-namespace:CRM.Tools.MetadataBrowser.Helpers"
                    xmlns:primitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data"
                 xmlns:layout="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Layout.Toolkit"
           d:DesignWidth="940" d:DesignHeight="480"
           Title="Entity View"
           Style="{StaticResource PageStyle}">
    <UserControl.Resources>
        <local:ObjectConverter x:Key="ConvertObject" />

    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" >

        <Grid.RowDefinitions>
            <RowDefinition Height="30" ></RowDefinition>
            <RowDefinition></RowDefinition>
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0" Background="DarkGray" Height="30" >
            <Button Name="uxExport" Click="Export_Click" Content="Export to Excel" Width="120" Height="25" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="2" />

        </StackPanel>
        <!-- Create a simple TabControl in XAML. -->
        <sdk:TabControl x:Name="uxTab" Grid.Row="1" >
            <sdk:TabItem Header="Attributes">
                <Grid HorizontalAlignment="Stretch">
                    <data:DataGrid AutoGenerateColumns="False"  HorizontalAlignment="Stretch"  Name="uxData" IsReadOnly="True"  >
                        <data:DataGrid.ColumnHeaderStyle>
                            <Style TargetType="primitives:DataGridColumnHeader" >
                                <Setter Property="FontSize" Value="12" />
                                <Setter Property="FontWeight" Value="Bold"  />
                                <Setter Property="Margin" Value="0" />
                                <Setter Property="Padding" Value="2" />
                                <Setter Property="VerticalContentAlignment" Value="Bottom" />
                                <Setter Property="Height" Value="140" />
                                <Setter Property="ContentTemplate" >
                                    <Setter.Value>
                                        <DataTemplate >
                                            <layout:LayoutTransformer>
                                                <layout:LayoutTransformer.LayoutTransform>
                                                    <RotateTransform Angle="-35"/>
                                                </layout:LayoutTransformer.LayoutTransform>
                                                <TextBlock Text="{Binding}" TextWrapping="Wrap"   />
                                            </layout:LayoutTransformer>
                                        </DataTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </data:DataGrid.ColumnHeaderStyle>

                        <data:DataGrid.Columns>
                            <data:DataGridTextColumn Header="Logical Name" Binding="{Binding LogicalName, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Schema Name" Binding="{Binding SchemaName, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Display Name" Binding="{Binding DisplayName, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Attribute Type" Binding="{Binding AttributeType, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Description" Binding="{Binding Description, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Required Level" Binding="{Binding RequiredLevel, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Audit Enabled" Binding="{Binding IsAuditEnabled, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Custom Attribute" Binding="{Binding IsCustomAttribute, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Customizable" Binding="{Binding IsCustomizable, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Managed" Binding="{Binding IsManaged, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is PrimaryId" Binding="{Binding IsPrimaryId, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Primary Name" Binding="{Binding IsPrimaryName, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Renameable" Binding="{Binding IsRenameable, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Secured" Binding="{Binding IsSecured, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Valid For Advanced Find" Binding="{Binding IsValidForAdvancedFind, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Valid For Create" Binding="{Binding IsValidForCreate, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Valid For Read" Binding="{Binding IsValidForRead, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Valid For Update" Binding="{Binding IsValidForUpdate, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Can Be Secured For Create" Binding="{Binding CanBeSecuredForCreate, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Can Be Secured For Read" Binding="{Binding CanBeSecuredForRead, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Can Be Secured For Update" Binding="{Binding CanBeSecuredForUpdate, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Can Modify Additional Settings" Binding="{Binding CanModifyAdditionalSettings, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Attribute Of" Binding="{Binding AttributeOf, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Entity Logical Name" Binding="{Binding EntityLogicalName, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Column Number" Binding="{Binding ColumnNumber, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Linked Attribute Id" Binding="{Binding LinkedAttributeId, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Deprecated Version" Binding="{Binding DeprecatedVersion, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Metadata Id" Binding="{Binding MetadataId, Converter={StaticResource ConvertObject}}" />
                        </data:DataGrid.Columns>
                    </data:DataGrid>
                </Grid>
            </sdk:TabItem>
            
            <sdk:TabItem Header=" N:1 Relationships">
                <Grid HorizontalAlignment="Stretch" >
                    <data:DataGrid Grid.Row="1" AutoGenerateColumns="False"  HorizontalAlignment="Stretch"  Name="uxManyToOne" IsReadOnly="True" >
                        <data:DataGrid.ColumnHeaderStyle>
                            <Style TargetType="primitives:DataGridColumnHeader" >
                                <Setter Property="FontSize" Value="12" />
                                <Setter Property="FontWeight" Value="Bold"  />
                                <Setter Property="Margin" Value="0" />
                                <Setter Property="Padding" Value="2" />
                                <Setter Property="VerticalContentAlignment" Value="Bottom" />
                                <Setter Property="Height" Value="140" />
                                <Setter Property="ContentTemplate" >
                                    <Setter.Value>
                                        <DataTemplate >
                                            <layout:LayoutTransformer>
                                                <layout:LayoutTransformer.LayoutTransform>
                                                    <RotateTransform Angle="-35"/>
                                                </layout:LayoutTransformer.LayoutTransform>
                                                <TextBlock Text="{Binding}" TextWrapping="Wrap"   />
                                            </layout:LayoutTransformer>
                                        </DataTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </data:DataGrid.ColumnHeaderStyle>
                        <data:DataGrid.Columns>
                            <data:DataGridTextColumn Header="Schema Name" Binding="{Binding SchemaName, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Referencing Entity" Binding="{Binding ReferencingEntity, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Referenced Entity" Binding="{Binding ReferencedEntity, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Referencing Attribute" Binding="{Binding ReferencingAttribute, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Referenced Attribute" Binding="{Binding ReferencedAttribute, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Associated Menu Configuration" Binding="{Binding AssociatedMenuConfiguration, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Cascade Configuration" Binding="{Binding CascadeConfiguration, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Custom Relationship" Binding="{Binding IsCustomRelationship, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Customizable" Binding="{Binding IsCustomizable, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Managed" Binding="{Binding IsManaged, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Valid For Advanced Find" Binding="{Binding IsValidForAdvancedFind, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Security Types" Binding="{Binding SecurityTypes, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Metadata Id" Binding="{Binding MetadataId, Converter={StaticResource ConvertObject}}" />
                        </data:DataGrid.Columns>
                    </data:DataGrid>
                </Grid>
            </sdk:TabItem>
            
            <sdk:TabItem Header="N:N Relationships">
                <Grid HorizontalAlignment="Stretch" >
                    <data:DataGrid Grid.Row="3" AutoGenerateColumns="False" HorizontalAlignment="Stretch"  Name="uxManyToMany" IsReadOnly="True" >
                        <data:DataGrid.ColumnHeaderStyle>
                            <Style TargetType="primitives:DataGridColumnHeader" >
                                <Setter Property="FontSize" Value="12" />
                                <Setter Property="FontWeight" Value="Bold"  />
                                <Setter Property="Margin" Value="0" />
                                <Setter Property="Padding" Value="2" />
                                <Setter Property="VerticalContentAlignment" Value="Bottom" />
                                <Setter Property="Height" Value="140" />
                                <Setter Property="ContentTemplate" >
                                    <Setter.Value>
                                        <DataTemplate >
                                            <layout:LayoutTransformer>
                                                <layout:LayoutTransformer.LayoutTransform>
                                                    <RotateTransform Angle="-35"/>
                                                </layout:LayoutTransformer.LayoutTransform>
                                                <TextBlock Text="{Binding}" TextWrapping="Wrap"   />
                                            </layout:LayoutTransformer>
                                        </DataTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </data:DataGrid.ColumnHeaderStyle>
                        <data:DataGrid.Columns>
                            <data:DataGridTextColumn Header="Schema Name" Binding="{Binding SchemaName, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Entity 1 Logical Name" Binding="{Binding Entity1LogicalName, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Entity 2 Logical Name" Binding="{Binding Entity2LogicalName, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Entity 1 Intersect Attribute" Binding="{Binding Entity1IntersectAttribute, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Entity 2 Intersect Attribute" Binding="{Binding Entity2IntersectAttribute, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Entity 2 Associated Menu Configuration" Binding="{Binding Entity2AssociatedMenuConfiguration, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Entity 1 Associated Menu Configuration" Binding="{Binding Entity1AssociatedMenuConfiguration, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Custom Relationship" Binding="{Binding IsCustomRelationship, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Customizable" Binding="{Binding IsCustomizable, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Managed" Binding="{Binding IsManaged, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Valid For Advanced Find" Binding="{Binding IsAuditEnabledIsValidForAdvancedFind, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Security Types" Binding="{Binding ReferencingAttribute, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Metadata Id" Binding="{Binding ReferencingEntity, Converter={StaticResource ConvertObject}}" />
                        </data:DataGrid.Columns>
                    </data:DataGrid>
                </Grid>
            </sdk:TabItem>
            
            <sdk:TabItem Header="1:N Relationships">
                <Grid HorizontalAlignment="Center" >
                    <data:DataGrid Grid.Row="5" AutoGenerateColumns="False"  HorizontalAlignment="Stretch"  Name="uxOneToMany" IsReadOnly="True" >
                        <data:DataGrid.ColumnHeaderStyle>
                            <Style x:Name="AngleHeader"  TargetType="primitives:DataGridColumnHeader" >
                                <Setter Property="FontSize" Value="12" />
                                <Setter Property="FontWeight" Value="Bold"  />
                                <Setter Property="Margin" Value="0" />
                                <Setter Property="Padding" Value="2" />
                                <Setter Property="VerticalContentAlignment" Value="Bottom" />
                                <Setter Property="Height" Value="140" />
                                <Setter Property="ContentTemplate" >
                                    <Setter.Value>
                                        <DataTemplate >
                                            <layout:LayoutTransformer>
                                                <layout:LayoutTransformer.LayoutTransform>
                                                    <RotateTransform Angle="-35"/>
                                                </layout:LayoutTransformer.LayoutTransform>
                                                <TextBlock Text="{Binding}" TextWrapping="Wrap"   />
                                            </layout:LayoutTransformer>
                                        </DataTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </data:DataGrid.ColumnHeaderStyle>
                        <data:DataGrid.Columns>
                            <data:DataGridTextColumn Header="Schema Name" Binding="{Binding SchemaName, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Referencing Entity" Binding="{Binding ReferencingEntity, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Referenced Entity" Binding="{Binding ReferencedEntity, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Referencing Attribute" Binding="{Binding ReferencingAttribute, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Referenced Attribute" Binding="{Binding ReferencedAttribute, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Associated Menu Configuration" Binding="{Binding AssociatedMenuConfiguration, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Cascade Configuration" Binding="{Binding CascadeConfiguration, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Custom Relationship" Binding="{Binding IsCustomRelationship, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Customizable" Binding="{Binding IsCustomizable, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Managed" Binding="{Binding IsManaged, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridCheckBoxColumn Header="Is Valid For Advanced Find" Binding="{Binding IsValidForAdvancedFind, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Security Types" Binding="{Binding SecurityTypes, Converter={StaticResource ConvertObject}}" />
                            <data:DataGridTextColumn Header="Metadata Id" Binding="{Binding MetadataId, Converter={StaticResource ConvertObject}}" />
                        </data:DataGrid.Columns>
                    </data:DataGrid>
                </Grid>
            </sdk:TabItem>
        </sdk:TabControl>
      

    </Grid>

   
</navigation:Page>
